<template>
  <div>
    <!-- 搜索栏 -->
    <el-card id="search">
      <el-row>
        <el-col :span="20">
          <el-input
            v-model="searchModel.name"
            placeholder="姓名"
            clearable
          />
          <el-input
            v-model="searchModel.upTime"
            placeholder="时间"
            clearable
          />
          <el-button
            type="primary"
            round
            icon="el-icon-search"
            @click="getEleInfo"
          >查询
          </el-button>
        </el-col>
      </el-row>
    </el-card>

    <!-- 结果列表 -->
    <el-card>
      <el-table :data="eleInfo" stripe style="width: 100%">
        <el-table-column label="#" width="80">
          <template slot-scope="scope">
            <!-- (pageNo-1) * pageSize + index + 1 -->
            {{
              (searchModel.pageNo - 1) * searchModel.pageSize + scope.$index + 1
            }}
          </template>
        </el-table-column>
        <el-table-column prop="name" label="用户姓名" width="180"/>
        <el-table-column prop="upTime" label="上传时间" width="180"/>
        <el-table-column prop="selectNum" label="选择个数" width="180"/>
      </el-table>
    </el-card>

    <!-- 分页组件 -->
    <el-pagination
      :current-page="searchModel.pageNo"
      :page-sizes="[10000]"
      :page-size="searchModel.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import tbApi from '@/api/tb'

export default {
  data() {
    return {
      formLabelWidth: '130px',
      userForm: {
        tbLink: '',
        priceLink: '',
        name: ''
      },
      dialogFormVisible: false,
      editInfo: false,
      total: 0,
      searchModel: {
        pageNo: 1,
        pageSize: 10000,
        upTime: '',
        name: ''
      },
      eleInfo: []
    }
  },
  created() {
    this.getEleInfo()
  },
  methods: {
    handleSizeChange(pageSize) {
      this.searchModel.pageSize = pageSize
      this.getEleInfo()
    },
    handleCurrentChange(pageNo) {
      this.searchModel.pageNo = pageNo
      this.getEleInfo()
    },
    getEleInfo() {
      tbApi.getEleInfo(this.searchModel).then((response) => {
        this.eleInfo = response.data.rows
        this.total = response.data.total
      })
    }
  }
}
</script>

<style>
#search .el-input {
  width: 200px;
  margin-right: 10px;
}

.el-dialog .el-input {
  width: 85%;
}

.blue-link {
  color: blue;
}

</style>
